<?xml version="1.0" encoding="UTF-8"?>
<!--
        Copyright  1990-2008 Sun Microsystems, Inc. All Rights Reserved.
        DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
        
        This program is free software; you can redistribute it and/or
        modify it under the terms of the GNU General Public License version
        2 only, as published by the Free Software Foundation.
        
        This program is distributed in the hope that it will be useful, but
        WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
        General Public License version 2 for more details (a copy is
        included at /legal/license.txt).
        
        You should have received a copy of the GNU General Public License
        version 2 along with this work; if not, write to the Free Software
        Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
        02110-1301 USA
        
        Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
        Clara, CA 95054 or visit www.sun.com if you need additional
        information or have any questions.
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>

<!-- stylesheet parameter: output file type (java | native) -->
<xsl:param name="output">error</xsl:param>

<xsl:template match="/">
<xsl:text>/*
 * Copyright  1990-2008 Sun Microsystems, Inc. All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version
 * 2 only, as published by the Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License version 2 for more details (a copy is
 * included at /legal/license.txt).
 * 
 * You should have received a copy of the GNU General Public License
 * version 2 along with this work; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 * 
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
 * Clara, CA 95054 or visit www.sun.com if you need additional
 * information or have any questions.
 *
 */

/*
 * This file is automatically generated. Do not edit.
 */

</xsl:text>
<xsl:if test="$output='java'">
<xsl:text>package com.sun.midp.security;

public final class PermissionsStrings {</xsl:text>
</xsl:if>
<xsl:variable name="perm_ids">
    <xsl:for-each select="/configuration/permissions/group">
        <xsl:for-each select="permission">
<xsl:text>
    /** </xsl:text>
<xsl:value-of select="@Name"/>
<xsl:text> permission ID. */
    public static final int </xsl:text>
<xsl:value-of select="@ID"/>
<xsl:text> = </xsl:text>
<xsl:text>;</xsl:text>
        </xsl:for-each>
    </xsl:for-each>
</xsl:variable>

<xsl:variable name="perm_number" select="59"/>

<xsl:if test="$output='native'">
<xsl:text>/** Total number of permissions. */
#define NUMBER_OF_PERMISSIONS    </xsl:text>
    <xsl:call-template name="generateNumberOfPermissions">
        <xsl:with-param name="text" select="$perm_ids"/>
        <xsl:with-param name="nextID" select="$perm_number"/>
    </xsl:call-template>
<xsl:text>
</xsl:text>
</xsl:if>

<xsl:if test="$output='java'">
<xsl:text>
    /* Permission Strings. */
    static final String [] PERMISSION_STRINGS =  {
        "javax.microedition.io.Connector.http",
        "javax.microedition.io.Connector.socket",
        "javax.microedition.io.Connector.https",
        "javax.microedition.io.Connector.ssl",
        "javax.microedition.io.Connector.serversocket",
        "javax.microedition.io.Connector.datagram",
        "javax.microedition.io.Connector.datagramreceiver",
        "javax.microedition.io.Connector.comm",
        "javax.microedition.io.PushRegistry",
        "javax.microedition.io.Connector.sms",
        "javax.microedition.io.Connector.cbs",
        "javax.wireless.messaging.sms.send",
        "javax.wireless.messaging.sms.receive",
        "javax.wireless.messaging.cbs.receive",
        "javax.microedition.media.control.RecordControl",
        "javax.microedition.media.control.VideoControl.getSnapshot",
        "javax.microedition.io.Connector.mms",
        "javax.wireless.messaging.mms.send",
        "javax.wireless.messaging.mms.receive",
        "javax.microedition.apdu.aid",
        "javax.microedition.jcrmi",
        "javax.microedition.securityservice.CMSMessageSignatureService",
        "javax.microedition.apdu.sat",
        "javax.microedition.content.ContentHandler",
        "javax.microedition.pim.ContactList.read",
        "javax.microedition.pim.ContactList.write",
        "javax.microedition.pim.EventList.read",
        "javax.microedition.pim.EventList.write",
        "javax.microedition.pim.ToDoList.read",
        "javax.microedition.pim.ToDoList.write",
        "javax.microedition.io.Connector.file.read",
        "javax.microedition.io.Connector.file.write",
        "javax.microedition.io.Connector.obex.client",
        "javax.microedition.io.Connector.obex.server",
        "javax.microedition.io.Connector.obex.client.tcp",
        "javax.microedition.io.Connector.obex.server.tcp",
        "javax.microedition.io.Connector.bluetooth.client",
        "javax.microedition.io.Connector.bluetooth.server",
        "javax.microedition.location.Location",
        "javax.microedition.location.Orientation",
        "javax.microedition.location.ProximityListener",
        "javax.microedition.location.LandmarkStore.read",
        "javax.microedition.location.LandmarkStore.write",
        "javax.microedition.location.LandmarkStore.category",
        "javax.microedition.location.LandmarkStore.management",
        "javax.microedition.io.Connector.sip",
        "javax.microedition.io.Connector.sips",
        "javax.microedition.payment.process",
        "javax.microedition.amms.control.camera.enableShutterFeedback",
        "javax.microedition.amms.control.tuner.setPreset",
        "javax.microedition.io.Connector.sensor",
        "javax.microedition.sensor.PrivateSensor",
        "javax.microedition.sensor.ProtectedSensor",
        "javax.microedition.contactless.DiscoveryManager",
        "javax.microedition.contactless.ndef.NDEFTagConnection.write",
        "javax.microedition.io.Connector.ndef",
        "javax.microedition.io.Connector.rf",
        "javax.microedition.io.Connector.sc",
        "javax.microedition.io.Connector.vtag",
</xsl:text>
        <xsl:for-each select="/configuration/permissions/group">
            <xsl:for-each select="permission">
<xsl:text>        "</xsl:text>
<xsl:value-of select="@Name"/>
<xsl:text>",
</xsl:text>
            </xsl:for-each>
        </xsl:for-each>
<xsl:text>    };
}
</xsl:text>
</xsl:if>
</xsl:template>

<xsl:template name="generateNumberOfPermissions">
    <xsl:param name="text"/>
    <xsl:param name="nextID"/>
<xsl:choose>
    <!-- when there is more than one element in the list -->
    <xsl:when test="contains($text,';')">
        <xsl:call-template name="generateNumberOfPermissions">
            <xsl:with-param name="text" select="substring-after($text,';')"/>
            <xsl:with-param name="nextID" select="$nextID + 1"/>
        </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
        <xsl:value-of select="$nextID"/>
    </xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>
